import { http } from "@/utils/http";

/** MQTT连接选项模型定义 */
export type MqttConnectOption = {
  tag: number; // 0 emqx 1 mochi
  protocol: string; // http 或者 https 代表是否加密 默认http
  host: string;
  publicHost: string;
  port: number;
  user: string;
  password: string;
  clientId: string;
  topics: string[]; // 订阅哪些主题
  apiUser: string;
  apiPassword: string;
  apiPort: number;
  websocketPort: number;
};

/** 系统自定义配置模型定义 */
export type SysConfigCustom = {
  platformName: string; // 平台名称
  platformAbbr: string; // 平台简称
  platformLogo: string; // 平台LOGO
  copyrightInfo: string; // 平台版权信息
};

/** 获取Web MQTT信息 */
export const getWebMqttInfoApi = () => {
  return http.request<Resp<{
    info: MqttConnectOption
  }>>('get', '/qcpublic/getWebMqttInfo');
};

/** 获取系统自定义配置信息 */
export const getSysCustomConfigApi = () => {
  return http.request<Resp<{
    info: SysConfigCustom
  }>>('get', '/qcpublic/getSysCustomConfig');
};
